(async function() { const chartData = {"datasets":[{"label":"Surface Temperature","backgroundColor":"#CCBB44"},{"label":"Soil Temperature at Ground Surface","data":[{"x":0,"y":22.4},{"x":-1,"y":22.2},{"x":-2,"y":22},{"x":-3,"y":22},{"x":-4,"y":22.2},{"x":-5,"y":22.2},{"x":-6,"y":22.4},{"x":-7,"y":22.4},{"x":-8,"y":22.5},{"x":-9,"y":22.5},{"x":-10,"y":22.7},{"x":-11,"y":22.7},{"x":-12,"y":22.7},{"x":-13,"y":22.9},{"x":-14,"y":22.9},{"x":-15,"y":23.1},{"x":-16,"y":23.1},{"x":-17,"y":23.3},{"x":-18,"y":23.4},{"x":-19,"y":23.6},{"x":-20,"y":23.4},{"x":-21,"y":23.4},{"x":-22,"y":23.3},{"x":-23,"y":22.9}],"backgroundColor":"#BB5566"},{"label":"Soil Temperature At 30 Cm Depth","data":[{"x":0,"y":25.2},{"x":-1,"y":25.2},{"x":-2,"y":25.2},{"x":-3,"y":25.2},{"x":-4,"y":25.2},{"x":-5,"y":25.2},{"x":-6,"y":25.2},{"x":-7,"y":25.1},{"x":-8,"y":25.1},{"x":-9,"y":25.1},{"x":-10,"y":25.1},{"x":-11,"y":25.1},{"x":-12,"y":25.1},{"x":-13,"y":25.1},{"x":-14,"y":36.6},{"x":-15,"y":24.9},{"x":-16,"y":24.9},{"x":-17,"y":24.9},{"x":-18,"y":24.9},{"x":-19,"y":24.9},{"x":-20,"y":24.7},{"x":-21,"y":24.7},{"x":-22,"y":24.7},{"x":-23,"y":24.7}],"backgroundColor":"#004488"}]} ctx = document.getElementById('groundTemp').getContext('2d'); chart = new Chart(ctx, { type: 'scatter', data: chartData, showLine: true, options: { scales: { x: { title: { display: true, text: 'Hours', font: { size: 16 }, } }, y: { title: { display: true, text: '°F', font: { size: 16 }, }, } } } }) if(chartData.datasets[0].data.length === 0) { const width = chart.width const height = chart.height const chart_ctx = chart.ctx; var fontSize = (height / 114).toFixed(2); chart_ctx.font = fontSize + "em sans-serif"; chart_ctx.fillStyle = "red"; chart_ctx.textBaseline = "middle"; var text = 'No Data', textX = Math.round((width - ctx.measureText(text).width) / 2), textY = height / 2; ctx.fillText(text, textX, textY); } })();